package com.admin.service;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;

import com.bean.Admin;
import com.bean.Pet;
import com.bean.Type;
import com.bean.User;
import com.admin.dao.BackgroundDao;
@Service("backgroundService")
public class BackgroundServiceImp implements BackgroundService {
	@Autowired BackgroundDao backgroundDao;
	
	public String getUser(Model model) {
		// TODO Auto-generated method stub
		List<User>list=backgroundDao.selectUser();
		model.addAttribute("list",list);
		return "admin/UserShow";
	}
	
	public String delUser(User user, Model model) {
		// TODO Auto-generated method stub
		int result=backgroundDao.delUser(user);
		if(result>0) {
			model.addAttribute("mess","操作成功");
			return "forward:getUser";
		}else {
			return "admin/fail";
		}
	}
	
	public String AdminSelectCommon(Model model) {
		// TODO Auto-generated method stub
		List<Map<String,Object>>list=backgroundDao.selectCommon();
		model.addAttribute("list",list);
		return "admin/commonshow";
	}

	
	public String AdminDeleteCommon(int common_id, Model model) {
		// TODO Auto-generated method stub
		int i=backgroundDao.AdminDeleteCommon(common_id);
		if(i>0) {
			model.addAttribute("mess","操作成功");
			List<Map<String,Object>>list=backgroundDao.selectCommon();
			model.addAttribute("list",list);
			return "admin/commonshow";
		}else {
			return "admin/fail";
		}
	}
}
